import 'package:flutter/material.dart';
import "package:get/get.dart";
import 'package:osg/controllers/http.dart';


class OsgAuthentication extends StatefulWidget {
  const OsgAuthentication({super.key});

  @override
  State<OsgAuthentication> createState() => _SettingPageState();
}

class _SettingPageState extends State<OsgAuthentication> {

    RxMap info={}.obs;
      @override
      void initState() {
        super.initState();

        
 WidgetsBinding.instance.addPostFrameCallback((_) {
      Get.find<HTTPS>().getData('/bbs/identity', {}).then((res){
              if(res!=null){
                 info.value=res;
              }
          });
    });

      
      }

  @override
  Widget build(BuildContext context) {
    final width = MediaQuery.of(context).size.width / 2.3;
    return Scaffold(
        body: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Stack(
          children: [
            Container(
              child: Image.asset(
                'static/images/osgrenzhen.png',
                fit: BoxFit.fitWidth,
              ),
            ),
            Positioned(
              left: 8.0,
              top: 20,
              child: IconButton(
                onPressed: () {
                  Get.back();
                  print('object');
                },
                icon: Image.asset(
                  'static/images/back.png',
                  width: 22,
                  fit: BoxFit.fitWidth,
                ),
              ),
            ),
          ],
        ),
        Container(
          height: 20,
          transform: Matrix4.translationValues(0.0, -10.0, 0.0),
          decoration: BoxDecoration(
              color: Color(0xffffffff),
              borderRadius: BorderRadius.circular(20)),
        ),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: 15),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              GestureDetector(
                onTap: () {
                  // Get.toNamed('/identification?type=1')

                  if(info['type']==1){
                     if(info['title'].length > 0){
                        Get.toNamed('/examine?type=1&status=${info['status']}&title=${info['title']}&reason=${info['reason']}');
                      }else{
                        Get.toNamed('/identification?type=1');
                      }
                  }else{

                    Get.toNamed('/identification?type=1');

                    //Get.find<HTTPS>().showTost('你申请企业认证中');

                       
                 }



                },
                child:Stack(
                  children: [
                      Image.asset(
                'static/images/geren.png',
                fit: BoxFit.fitWidth,
                width: width,
              ),

                Positioned(
                    bottom: 20,
                    left: 0,
                    right: 0,
                    child: 
                    Align(
                      child: 
              Obx(()=>
                info['type']==1?
                Text(info['status']==1?'已通过':info['status']==2?'已驳回':'审核中',style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18,color:
                info['status']==1?Color(0XFF06AA00):info['status']==2?Color(0XFFEF0000):Color.fromARGB(255, 40, 120, 255)
                ))
                : Container(
                      width: 70,
                      height: 30,
                      alignment: Alignment.center,
                       decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular((15)),
                            gradient: LinearGradient(
                            colors: [
                            Color(0xff2189E7),
                            Color(0xffBF67F8),
                            ], // 定义颜色列表
                            begin: Alignment.topLeft, // 渐变开始的位置
                            end: Alignment.bottomRight, // 渐变结束的位置
                            ),
                            ),
                      child: Text('去认证',style: TextStyle(fontSize: 12,color: Color(0XFFFFFFFF))),
                    )
              )

                  )
                  )
                  
                  ],
                )
                
                
              ),

              GestureDetector(
                onTap: () {
                  //Get.toNamed('/enterprise_certification');
                  
                    if(info['type']==2){
                        if(info['title'].length > 0){
                          Get.toNamed('/examine?type=2&status=${info['status']}&title=${info['title']}&reason=${info['reason']}');
                        }else{
                          Get.toNamed('/identification?type=2');
                        }
                    }else{
                          Get.toNamed('/identification?type=2');

                      // Get.find<HTTPS>().showTost('你申请个人认证中');
                    }
             
                },
                child: Stack(
                  children: [
                      Image.asset(
                'static/images/zuzhirenzheng.png',
                fit: BoxFit.fitWidth,
                width: width,
              ),
                  Positioned(
                    bottom: 20,
                    left: 40,
                    right: 40,
                    child: 
Align(
                      child: 
              Obx(()=>
                info['type']==2?
                Text(info['status']==1?'已通过':info['status']==2?'驳回':'审核中',style: TextStyle(fontSize: 12,color:
                info['status']==1?Color(0XFF06AA00):info['status']==2?Color(0XFFEF0000):Color(0XFFEF0000)
                ))
                : Container(
                      width: 70,
                      height: 30,
                      alignment: Alignment.center,
                       decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular((15)),
                            gradient: LinearGradient(
                            colors: [
                            Color(0xff2189E7),
                            Color(0xffBF67F8),
                            ], // 定义颜色列表
                            begin: Alignment.topLeft, // 渐变开始的位置
                            end: Alignment.bottomRight, // 渐变结束的位置
                            ),
                            ),
                      child: Text('去认证',style: TextStyle(fontSize: 12,color: Color(0XFFFFFFFF))),
                    )
              )

                  )










               
                  )
                  ],
                )
                
                ,
              ),
              
            ],
          ),
        )
      ],
    ));
  }
}
